#pragma once

#include "rclcpp/rclcpp.hpp"

// ROS
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/msg/image.hpp>

// Custom
#include "virtual_camera/VirtualCamera.h"
//Choose

namespace virtual_camera {

class CameraNode : public rclcpp::Node {

public:
    CameraNode(const rclcpp::NodeOptions &options);
    ~CameraNode() = default;

private:
    /**
     * @brief 获取图像并发布
     *
     */
    void getImage();
    // 相机参数
    int image_width;
    int image_height;
    std::shared_ptr<VirtualCamera> camera;

    // 视频参数
    std::string video_name;
    std::shared_ptr<rclcpp::ParameterEventHandler> video_param_sub_;
    std::shared_ptr<rclcpp::ParameterCallbackHandle> video_cb_handle_;

    // FPS 参数
    int fps;
    std::shared_ptr<rclcpp::ParameterEventHandler> fps_param_sub_;
    std::shared_ptr<rclcpp::ParameterCallbackHandle> fps_cb_handle_;

    // 图像信息发布
    rclcpp::Publisher<sensor_msgs::msg::Image>::SharedPtr image_pub_;

    // 定时器
    rclcpp::TimerBase::SharedPtr timer_;

    // 图像的Quality of Service
    constexpr static const rmw_qos_profile_t _img_qos =
    {
        RMW_QOS_POLICY_HISTORY_KEEP_LAST,
        1,
        RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT,
        RMW_QOS_POLICY_DURABILITY_VOLATILE,
        RMW_QOS_DEADLINE_DEFAULT,
        RMW_QOS_LIFESPAN_DEFAULT,
        RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT,
        RMW_QOS_LIVELINESS_LEASE_DURATION_DEFAULT,
        false
    };
};


}